﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Warlock
{
    /// <summary>
    /// Basisklasse fuer fast alles, was auf dem Bildschirm gezeichnet wird.
    /// Update und Draw muss in der jeweiligen Update und Drawmethode des GameScreens aufgerufen werden.
    /// </summary>
    abstract class Sprite
    {
        public virtual Vector2 Position { get; set; }
        public virtual Texture2D Texture { get; set; }
        public virtual float Rotation { get; set; }
        public virtual float Scale { get; set; }

        public Vector2 RelativeCenter { get { return new Vector2(Width / 2, Height / 2); } }
        public Vector2 AbsoluteCenter { get { return new Vector2(X + Width / 2, Y + Height / 2); } }
        public float Width { get { return Texture.Width; } }
        public float Height { get { return Texture.Height; } }
        public float X { get { return Position.X; } }
        public float Y { get { return Position.Y; } }

        public Sprite()
        {
        }
        public Sprite(Vector2 position)
        {
            Position = position;
            Rotation = 0;
        }
        public virtual void LoadContent(ContentManager content)
        {
        }
        /// <summary>
        /// Update-Logik des Objekts. z.B. Cooldowns
        /// </summary>
        public virtual void Update(GameTime gameTime)
        {
        }
        /// <summary>
        /// Alles vom Objekt was gezeichnet werden muss.
        /// </summary>
        public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(Texture, Position, null, Color.White, Rotation, RelativeCenter, Scale, SpriteEffects.None, 0.8f);
        }
    }
}